﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.51    还款计划变更后信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_LOAN_PAYPLANNEW: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_LOAN_PAYPLANNEW()
		{}
		#region Model
		private long _id;
		private long _proid;
		private long _conid;
		private long _loanid;
		private Nullable<DateTime> _startdate;
		private Nullable<DateTime> _enddate;
		private int _intdays;
		private Nullable<DateTime> _paydate;
		private Nullable<DateTime> _maxpaydate;
		private int _phase;
		private decimal _capital;
		private decimal _interest;
		private decimal _cost;
		private decimal _fees;
		private decimal _delayrate;
		private int _status;
		private Nullable<DateTime> _createdate;
		private Nullable<DateTime> _recorddate;
		private int _chgtype;
		private long _pid;
		private int _chgstatus;
		/// <summary>
		/// 记录ID
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 立项申请记录ID
		/// </summary>
		[DataMember]
		public long PROID
		{
			get{return _proid;}
			set{
				if ( _proid!= value)
				{
					 _proid = value;
					OnPropertyChanged("PROID");
				}
			}
		}
		/// <summary>
		/// 合同记录ID
		/// </summary>
		[DataMember]
		public long CONID
		{
			get{return _conid;}
			set{
				if ( _conid!= value)
				{
					 _conid = value;
					OnPropertyChanged("CONID");
				}
			}
		}
		/// <summary>
		/// 放款记录ID
		/// </summary>
		[DataMember]
		public long LOANID
		{
			get{return _loanid;}
			set{
				if ( _loanid!= value)
				{
					 _loanid = value;
					OnPropertyChanged("LOANID");
				}
			}
		}
		/// <summary>
		/// 起息日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> STARTDATE
		{
			get{return _startdate;}
			set{
				if ( _startdate!= value)
				{
					 _startdate = value;
					OnPropertyChanged("STARTDATE");
				}
			}
		}
		/// <summary>
		/// 止息日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> ENDDATE
		{
			get{return _enddate;}
			set{
				if ( _enddate!= value)
				{
					 _enddate = value;
					OnPropertyChanged("ENDDATE");
				}
			}
		}
		/// <summary>
		/// 计息天数
		/// </summary>
		[DataMember]
		public int INTDAYS
		{
			get{return _intdays;}
			set{
				if ( _intdays!= value)
				{
					 _intdays = value;
					OnPropertyChanged("INTDAYS");
				}
			}
		}
		/// <summary>
		/// 应还日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> PAYDATE
		{
			get{return _paydate;}
			set{
				if ( _paydate!= value)
				{
					 _paydate = value;
					OnPropertyChanged("PAYDATE");
				}
			}
		}
		/// <summary>
		/// 最大应还日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> MAXPAYDATE
		{
			get{return _maxpaydate;}
			set{
				if ( _maxpaydate!= value)
				{
					 _maxpaydate = value;
					OnPropertyChanged("MAXPAYDATE");
				}
			}
		}
		/// <summary>
		/// 期数
		/// </summary>
		[DataMember]
		public int PHASE
		{
			get{return _phase;}
			set{
				if ( _phase!= value)
				{
					 _phase = value;
					OnPropertyChanged("PHASE");
				}
			}
		}
		/// <summary>
		/// 本金
		/// </summary>
		[DataMember]
		public decimal CAPITAL
		{
			get{return _capital;}
			set{
				if ( _capital!= value)
				{
					 _capital = value;
					OnPropertyChanged("CAPITAL");
				}
			}
		}
		/// <summary>
		/// 利息
		/// </summary>
		[DataMember]
		public decimal INTEREST
		{
			get{return _interest;}
			set{
				if ( _interest!= value)
				{
					 _interest = value;
					OnPropertyChanged("INTEREST");
				}
			}
		}
		/// <summary>
		/// 管理费
		/// </summary>
		[DataMember]
		public decimal COST
		{
			get{return _cost;}
			set{
				if ( _cost!= value)
				{
					 _cost = value;
					OnPropertyChanged("COST");
				}
			}
		}
		/// <summary>
		/// 手续费
		/// </summary>
		[DataMember]
		public decimal FEES
		{
			get{return _fees;}
			set{
				if ( _fees!= value)
				{
					 _fees = value;
					OnPropertyChanged("FEES");
				}
			}
		}
		/// <summary>
		/// 逾期利率以千分比为单位
		/// </summary>
		[DataMember]
		public decimal DELAYRATE
		{
			get{return _delayrate;}
			set{
				if ( _delayrate!= value)
				{
					 _delayrate = value;
					OnPropertyChanged("DELAYRATE");
				}
			}
		}
		/// <summary>
		/// 状态0未还，1部分还，2结清
		/// </summary>
		[DataMember]
		public int STATUS
		{
			get{return _status;}
			set{
				if ( _status!= value)
				{
					 _status = value;
					OnPropertyChanged("STATUS");
				}
			}
		}
		/// <summary>
		/// 生成时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CREATEDATE
		{
			get{return _createdate;}
			set{
				if ( _createdate!= value)
				{
					 _createdate = value;
					OnPropertyChanged("CREATEDATE");
				}
			}
		}
		/// <summary>
		/// 记录时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> RECORDDATE
		{
			get{return _recorddate;}
			set{
				if ( _recorddate!= value)
				{
					 _recorddate = value;
					OnPropertyChanged("RECORDDATE");
				}
			}
		}
		/// <summary>
		/// 记录类型1贷款收回，
        ///2手动结清，
        ///3展期变更，
        ///4还款日变更，
        ///5利率变更
		/// </summary>
		[DataMember]
		public int CHGTYPE
		{
			get{return _chgtype;}
			set{
				if ( _chgtype!= value)
				{
					 _chgtype = value;
					OnPropertyChanged("CHGTYPE");
				}
			}
		}
		/// <summary>
		/// 主表记录ID
		/// </summary>
		[DataMember]
		public long PID
		{
			get{return _pid;}
			set{
				if ( _pid!= value)
				{
					 _pid = value;
					OnPropertyChanged("PID");
				}
			}
		}
		/// <summary>
		/// 变更状态0不变，1变
		/// </summary>
		[DataMember]
		public int CHGSTATUS
		{
			get{return _chgstatus;}
			set{
				if ( _chgstatus!= value)
				{
					 _chgstatus = value;
					OnPropertyChanged("CHGSTATUS");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

